<?php
/**
 * Created by PhpStorm.
 * User: lubin
 * Date: 2018/7/29
 * Time: 下午9:23
 */

namespace app\api\validate;

class IDCollection extends BaseValidate
{
    protected $rule = [
        'ids'=>'require|checkIds'
    ];
    public $message = [
      'ids'=>'ids必须是以逗号分隔的正整数'
    ];
    public function checkIds($value){
        $values = explode(',',$value);
        if (empty($values)){
            return false;
        }
        foreach ($values as $id){
            if (!$this->isPositiveInteger($id)){
                return false;
            }
        }
        return true;
    }

}